Let’s say you have an EP with and deleted and inactive user. First, do a GET On the EP, then look at the escalation rules -> escalation targets section and you’ll see the users or schedules targets.
For the deleted/inactive user, the field “self” will be blank/null and you can use this condition to break out into logic to remove and update the EP. It will be the same for deleted/inactive users on a schedule.
"escalation_rules": [
{
"id": "PANZZEQ",
"escalation_delay_in_minutes": 30,
"targets": [
{
"id": "PEYSGVF",
"summary": "PagerDuty Admin",
"type": "user_reference",
"self": "https://api.pagerduty.com/users/PEYSGVF",
"html_url": "https://subdomain.pagerduty.com/users/PEYSGVF"
},
{
"id": "PEYSGVF",
"summary": "joe deleted",
"type": "user_reference",
"self": "",
"html_url": "https: subdomain.pagerduty.com/users/PEYSGVF"
},
{
"id": "PI7DH85",
"summary": "DailyEngineeringRotation",
"type": "schedule_reference",
"self": "https: //api.pagerduty.com/schedules/PI7DH85",
"html_url": "https: subdomain.pagerduty.com/schedules/PI7DH85"
}
]
}
]